package cn.nyse.ktc_find.service;


import cn.nyse.ktc_find.dao.ArticleSearchDao;
import cn.nyse.ktc_find.entity.Article;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;
import java.util.List;

/**
 * @Description 问题 服务层
 * @author admin
 * @date 2020-10-10 13:36:19
*/
@Service
//@Transactional
public class ArticleServiceImpl implements ArticleService{

	@Autowired
	private ArticleSearchDao articleDao;






	@Override
	public Page<Article> findAll(String keyword, int page, int size){
		return articleDao.findByTitleOrContent(keyword,keyword, PageRequest.of(page-1,size));
	}


	/**
	* 查询全部列表
	* @return
	*/
	@Override
	public List<Article> findAll() {
		return (List<Article>) articleDao.findAll();
	}





	/**
	* 根据ID查询实体
	* @param id
	* @return
	*/
	@Override
	public Article findById(String id) {
		return articleDao.findById(id).get();
	}

	/**
	* 增加
	* @param article
	*/
	@Override
	public void add(Article article) {
		articleDao.save(article);
	}

	/**
	* 修改
	* @param article
	*/
	@Override
	public void update(Article article) {
		articleDao.save(article);
	}

	/**
	* 删除
	* @param id
	*/
	@Override
	public void deleteById(String id) {
		articleDao.deleteById(id);
	}


}
